
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>4、内存分析 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>4、内存分析 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Java虚拟机定义了哪些主要的内存区域？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Java虚拟机定义了四个主要的内存区域：堆（Heap）、栈（Stack）、方法区（Method Area）和运行时常量池（Runtime Constant Pool）。</div>
          </div>
          <div class="card-source">来源: 1. 主要内存区域</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Java内存区域中，哪些是线程共享的，哪些是线程私有的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">堆（Heap）和方法区（Method Area）是所有线程共享的。栈（Stack）是线程私有的，每个线程都有自己的栈。</div>
          </div>
          <div class="card-source">来源: 1. 主要内存区域</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">堆（Heap）内存区域的主要作用是什么？由什么机制来管理？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">堆是Java程序中最大的内存区域，主要作用是存储对象实例和数组。它由GC（Garbage Collection，垃圾回收）机制负责管理对象的创建、分配和回收。</div>
          </div>
          <div class="card-source">来源: 2. 内存区域的作用和区别</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">方法区（Method Area）主要存储什么内容？在HotSpot虚拟机中它又被称为什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">方法区用于存储类信息、静态变量、常量池等。在HotSpot虚拟机中，方法区被称为永久代（PermGen）。</div>
          </div>
          <div class="card-source">来源: 1. 主要内存区域</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在Java程序中，通过`new`关键字创建的对象和方法的局部变量分别存放在哪个内存区域？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通过`new`关键字创建的对象存放在堆（Heap）中，而方法的局部变量（包括方法参数和方法内定义的变量）存放在栈（Stack）中。</div>
          </div>
          <div class="card-source">来源: 对象的内存分析</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">运行时常量池（Runtime Constant Pool）与方法区是什么关系？它有什么特点？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">运行时常量池是方法区的一部分。它存储着类文件中的常量信息，每个类都有自己的运行时常量池，并且可以动态添加新的常量。</div>
          </div>
          <div class="card-source">来源: 1. 主要内存区域</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">静态属性（static variable）在内存中有什么特点？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">静态属性存储在方法区中，其特点是无论一个类被实例化多少个对象，所有这些对象都共享同一份静态属性。</div>
          </div>
          <div class="card-source">来源: 作业</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">当执行代码 `String a = "凤姐"; String b = "凤姐";` 时，`a == b` 的结果为什么是true？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">因为字符串字面量（如"凤姐"）被存储在方法区的常量池中。当创建变量a时，"凤姐"被放入常量池。当创建变量b时，Java发现常量池中已存在该字符串，会直接将b指向该字符串的内存地址，因此a和b引用的是同一个对象。</div>
          </div>
          <div class="card-source">来源: 作业</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">栈（Stack）内存区域主要存放哪些内容？其数据是如何变化的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">栈是线程私有的内存区域，主要存储局部变量、方法调用、方法返回值等。栈中的数据随着方法的入栈和出栈而动态变化。</div>
          </div>
          <div class="card-source">来源: 2. 内存区域的作用和区别</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
